﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Aspfm.Factory.Main
{
    public class AspfmGlobal
    {
        public static void Application_Start(object sender, EventArgs e)
        {
            Aspfm.MainController.PageTool.InitConn();
            Aspfm.MainController.PageTool.WriteLog("IIS启动Start。。。。");
        }

        public static void Session_Start(object sender, EventArgs e)
        {

        }

        public static void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpContext.Current.Request.ValidateInput();
            Aspfm.MainController.PageTool.BeginRequestLogin();
            if (Aspfm.MainController.PageTool.CheckRole())
            {
                Aspfm.MainController.PageTool.CheckAspfm();
            }
            else
            {
                string str = Aspfm.MainController.PageTool.GetWebBaseUrl();
                System.Web.HttpContext.Current.Response.Redirect(str + "login", false);
            }
        }

        public static void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        public static void Application_Error(object sender, EventArgs e)
        {
            Exception objExp = HttpContext.Current.Server.GetLastError();
            Aspfm.MainController.PageTool.WriteLog(objExp);
        }

        public static void Session_End(object sender, EventArgs e)
        {

        }

        public static void Application_End(object sender, EventArgs e)
        {
            Aspfm.MainController.PageTool.InitConn();
            Aspfm.MainController.PageTool.WriteLog("IIS停止End。。。。");
        }
    }
}
